package com.lk.server.register;

import cn.hutool.core.map.MapUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author kun.li
 */
public class LocalRegister {

    private static final Map<String, Map<String, Object>> registerMap = new ConcurrentHashMap<>();

    public static void register(String interfaceName, String version, Object zClass) {
        Map<String, Object> versionMap = new HashMap<>();
        versionMap.put(version, zClass);
        registerMap.put(interfaceName, versionMap);
    }

    public static Object getService(String interfaceName, String version) {
        Map<String, Object> classMap = registerMap.get(interfaceName);
        if (MapUtil.isNotEmpty(classMap)) {
            return classMap.get(version);
        }
        return null;
    }


}
